<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的发布</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <style>
        html,
        body {
            background-color: #F7F7F7;
        }

        .arc_list {
            border: 1px solid #eee;
            padding: 0.5rem;
            margin-bottom: 0.5rem;
            position: relative;
        }

        .content {
            width: 100%;
            font-size: 0.7rem;
            color: #2B2B2B;
        }

        .time {
            font-size: 0.6rem;
            color: #999999;
        }

        .aui-label-outlined {
            padding: 0 3px;
            color: #ccc;
            position: absolute;
            right: 0.75rem;
            bottom: 0.75rem;
        }

        [v-clock] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app" v-clock>
        <div class="aui-content-padded">
            <div class="arc_list" v-for="o,i in list" @click="userRead(o.msgs_id,i)">
                <div class="aui-dot" v-if="o.is_read===0" style="right:5px;"></div>
                <div class="content">{{o.message}}</div>
                <div class="time">{{o.create_time}}</div>
                <div class="aui-label aui-label-outlined" @click.stop="del(o.msgs_id,i)">x</div>
            </div>
        </div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();

    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            list: [],

            listType: 1,
            listPage: 1,
            listStatus: true,
        },
        methods: {
            init() {
                this.upDownLoad();
                this.userInfo = get_local("userInfo");
                this.getList();
            },
            getList() {
                var that = this;
                var data = {
                    user_id: this.userInfo.user_id,
                    pages: this.listPage
                };
                _ajax(Config.api.UserMessageGetLists, data, function(ret) {
                    if (ret.code === 200) {
                        if (ret.data.length > 0) {
                            that.list = that.list.concat(ret.data);
                        } else {
                            that.listStatus = false;
                        }
                    }
                });
            },
            userRead(id, i) {
                var that = this;
                var data = {
                    user_id: this.userInfo.user_id,
                    msgs_id: id
                };
                _ajax(Config.api.UserMessageUserRead, data, function(ret) {
                    if (ret.code === 200) {
                        that.list[i].is_read = 1;
                        api.execScript({
                            name:'main',
                            frameName: 'my',
                            script: 'vm.gerUserInfo()'
                        });
                    }
                });
            },
            del(id, i) {
                var that = this;
                var data = {
                    user_id: this.userInfo.user_id,
                    msgs_id: id
                };
                _ajax(Config.api.UserMessageUserRemove, data, function(ret) {
                    if (ret.code === 200) {
                        that.list.splice(i, 1);
                        api.execScript({
                            name:'main',
                            frameName: 'my',
                            script: 'vm.gerUserInfo()'
                        });
                    }
                });
            },
            upDownLoad() {
                var that = this;

                // 下拉刷新
                push_down(function() {
                    //下拉刷新恢复
                    push_down_over();
                    that.listStatus = true;
                    that.listPage = 1;
                    that.list = [];
                    that.getList();
                });

                //上拉加载
                push_up(function() {
                    if (that.listStatus) {
                        that.listPage++;
                        that.getList();
                    }
                });
            },
            openWin(name) {
                var winInfo = {
                    to_quote: {
                        name: 'to_quote_win',
                        url: './to_quote_win.html'
                    }
                };
                if (name) {
                    open_w(winInfo[name].name, winInfo[name].url);
                } else {
                    $toast("正在开发中...");
                }
            }
        }
    });
</script>

</html>
